package com.finger.commonutil.exception;


import com.finger.modelservice.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result globalException(Exception e){

        return Result.fail().message(e.getMessage());
    }

    @ExceptionHandler(YyghException.class)
    public Result yyghException(YyghException e){

        return Result.build(e.getCode(),e.getMessage());
    }
}
